﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        CreateUserWizard1.CreatedUser += new EventHandler(CreateUserWizard1_CreatedUser);
    }

    void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        // lay user ma nguoi dung vua dang ky 
        string username = CreateUserWizard1.UserName;
        // sau khi nguoi dung dang ky tai khoan thanh cong 
        // thi add tai khoan do vao role Customers 
        Roles.AddUserToRole(username, "Customers");
        FormsAuthentication.SetAuthCookie(username, false);
        string continueUrl = CreateUserWizard1.ContinueDestinationPageUrl;
        if (String.IsNullOrEmpty(continueUrl))
            continueUrl = "~/";
        Response.Redirect(continueUrl);
    }
}